<%@page import="cart.ShoppingCart"%>
<div class="header">
    <div class="headerLeft">
        <a href="<%= request.getContextPath()%>"><img src="<%= request.getContextPath()%>/css/header.png" alt="header Banner" width="512" height="90" title="Go to Homepage"/></a>
    </div>
    <div class="headerRight">
        <div id="firstLine">
            <div id="firstLineLeft">
                <%
                    String cartStatus;
                    ShoppingCart scart = (ShoppingCart) session.getAttribute("shoppingCart");
                    if (scart == null) {
                        cartStatus = "0 Item";
                    } else if (scart.getTotalQuantity() == 0) {
                        cartStatus = "0 Item";
                    } else {
                        cartStatus = "$" + scart.getTotalAmount() + " - " + scart.getTotalQuantity() + " Item(s)";
                    }
                %>
                <s:url action="viewShoppingCart" var="viewShoppingCartUrl"></s:url>
                <s:a href="%{viewShoppingCartUrl}" cssClass="cartIcon topLine" title="View Shopping Cart Information"><% out.print(cartStatus);%></s:a>
            </div>
            <div id="firstLineRight">
                <%if (session.getAttribute("username") == null) {%>
                <div id="flr1">
                    <s:url namespace="/Member" action="loginForm" var="loginUrl"></s:url>
                    <s:a href="%{loginUrl}" cssClass="topLine" title="Click to Login">Login</s:a>
                </div>
                <div id="flr2">
                    <s:url namespace="/Member" action="registerForm" var="registerUrl"></s:url>
                    <s:a href="%{registerUrl}" cssClass="topLine" title="Click to Register">Register</s:a>
                </div>
                <%} else {%>
                <div id="flr1">
                    <p>Welcome, </p>
                    <s:url namespace="/Member" action="viewProfile" var="viewProfileUrl"></s:url>
                    <s:a href="%{viewProfileUrl}" cssClass="userProfile" title="View Profile"><b><% out.print(session.getAttribute("username").toString());%></b></s:a>
                </div>
                <div id="flr2">
                    <s:url namespace="/Member" action="logout" var="urlLogout"></s:url>
                    <a class="topLine" href="<s:property value="#urlLogout"/>" title="Logout">Logout</a>
                </div>
                <%}%>
            </div>
        </div>
        <div id="secondLine">
            <div id="sl1">
                <s:form action="searchProduct" namespace="/">
                    <s:textfield name="keyword" size="30" theme="simple" />
                    <s:submit value="Search" cssStyle="width: 64px; margin-left: 12px" theme="simple" title="Quick Search"/>
                </s:form>
            </div>
            <div id="sl2">
                <s:url action="searchForm" namespace="/" var="searchUrl"></s:url>
                <s:a href="%{searchUrl}" cssClass="topLine" title="Go to Advanced Search Page">Advanced Search</s:a>
            </div>
        </div>
        <div id="thirdLine">
            <s:url action="home" namespace="/" var="homeUrl"></s:url>
            <s:url action="sale" namespace="/" var="saleUrl"></s:url>
            <s:url action="best-selling" namespace="/" var="bestSellingUrl"></s:url>
            <s:url action="about" namespace="/" var="aboutUrl"></s:url>
            <s:url action="contact" namespace="/" var="contactUrl"></s:url>
            <s:url action="help" namespace="/" var="helpUrl"></s:url>

            <!--<div class="hNav"><s:a href="%{helpUrl}"  title="Click for Help">Help</s:a></div>-->
            <!--<div class="hNav"><s:a href="%{contactUrl}"  title="Contact Us">Contact</s:a></div>-->
            <div class="hNav"><s:a href="%{aboutUrl}"  title="About Us">About</s:a></div>
            <div class="hNav"><s:a href="%{bestSellingUrl}"  title="Best Selling Products">Best Selling</s:a></div>
            <div class="hNav"><s:a href="%{saleUrl}"  title="Hot Sale Products">Sale</s:a></div>
            <div class="hNav" style="border: none;"><s:a href="%{homeUrl}"  title="Home - Lastest Products">Home</s:a></div>
        </div>
    </div>
</div>